package net.lab1024.sa.admin.module.crawler.controller;

import net.lab1024.sa.admin.module.crawler.domain.form.*;
import net.lab1024.sa.admin.module.crawler.domain.vo.ShopCookieVO;
import net.lab1024.sa.admin.module.crawler.domain.vo.ShopVO;
import net.lab1024.sa.admin.module.crawler.service.ShopService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;

import java.util.List;

/**
 * 门店 Controller
 *
 * @Author -
 * @Date 2025-03-21 08:31:36
 * @Copyright -
 */

@RestController
@Tag(name = "门店")
public class ShopController {

    @Resource
    private ShopService shopService;

    @Operation(summary = "分页查询 @author -")
    @PostMapping("/shop/queryPage")
    @SaCheckPermission("shop:query")
    public ResponseDTO<PageResult<ShopVO>> queryPage(@RequestBody @Valid ShopQueryForm queryForm) {
        return ResponseDTO.ok(shopService.queryPage(queryForm));
    }

    @Operation(summary = "下拉选查询 @author -")
    @PostMapping("/shop/selectList")
    @SaCheckPermission("shop:query")
    public ResponseDTO<List<ShopVO>> selectList(@RequestBody ShopselectListQueryForm queryForm) {
        return ResponseDTO.ok(shopService.selectList(queryForm));
    }


    @Operation(summary = "获取mtgsig @author -")
    @PostMapping("/shop/requestUrlParam")
    @SaCheckPermission("shop:query")
    public ResponseDTO<String> requestUrlParam(@RequestBody RequestUrlParmForm form) {
        return shopService.getMtRequestUrl(form);
    }


    @Operation(summary = "获取cookie @author -")
    @GetMapping("/shop/info/{id}")
    @SaCheckPermission("shop:query")
    public ResponseDTO<ShopCookieVO> info(@PathVariable("id") Long id) {
        return null;//shopService.getShopInfoById(id);
    }

    @Operation(summary = "添加 @author -")
    @PostMapping("/shop/add")
    @SaCheckPermission("shop:add")
    public ResponseDTO<String> add(@RequestBody @Valid ShopAddForm addForm) {
        return shopService.add(addForm);
    }

    @Operation(summary = "更新 @author -")
    @PostMapping("/shop/update")
    @SaCheckPermission("shop:update")
    public ResponseDTO<String> update(@RequestBody @Valid ShopUpdateForm updateForm) {
        return shopService.update(updateForm);
    }


    @Operation(summary = "批量删除 @author -")
    @PostMapping("/shop/batchDelete")
    @SaCheckPermission("shop:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
        return shopService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author -")
    @GetMapping("/shop/delete/{id}")
    @SaCheckPermission("shop:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Long id) {
        return shopService.delete(id);
    }
}
